/* eslint-disable */
// @ts-ignore
import { queryOptions, useMutation } from '@tanstack/vue-query';
import type { DefaultError } from '@tanstack/vue-query';
import request from '@/utils/request';
import { CustomRequestOptions } from '@/interceptors/request';

import * as apis from './redeemRecordController';
import * as API from './types';

/** 优惠券兑换记录新增 POST /api/redeem/add */
export function useAddUsingPost2Mutation(options?: {
  onSuccess?: (value?: API.AjaxResultobject) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.addUsingPost2,
    onSuccess(data: API.AjaxResultobject) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 优惠券兑换记录删除 POST /api/redeem/del */
export function useDelUsingPost2Mutation(options?: {
  onSuccess?: (value?: API.AjaxResultobject) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.delUsingPost2,
    onSuccess(data: API.AjaxResultobject) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 优惠券兑换记录详情 GET /api/redeem/detail */
export function detailUsingGet5QueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.detailUsingGET5Params;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.detailUsingGet5(queryKey[1] as typeof options);
    },
    queryKey: ['detailUsingGet5', options],
  });
}

/** 优惠券兑换记录编辑 POST /api/redeem/edit */
export function useEditUsingPost2Mutation(options?: {
  onSuccess?: (value?: API.AjaxResultobject) => void;
  onError?: (error?: DefaultError) => void;
}) {
  const { onSuccess, onError } = options || {};

  const response = useMutation({
    mutationFn: apis.editUsingPost2,
    onSuccess(data: API.AjaxResultobject) {
      onSuccess?.(data);
    },
    onError(error) {
      onError?.(error);
    },
  });

  return response;
}

/** 优惠券兑换记录列表 GET /api/redeem/list */
export function listUsingGet6QueryOptions(options: {
  // 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
  params: API.listUsingGET6Params;
  options?: CustomRequestOptions;
}) {
  return queryOptions({
    queryFn: async ({ queryKey }) => {
      return apis.listUsingGet6(queryKey[1] as typeof options);
    },
    queryKey: ['listUsingGet6', options],
  });
}
